
import { defineStore } from 'pinia';

export const userStore = defineStore('userStore', {
	state: () => ({
		message: 'vue3_pinia_用户信息',
		userid: 0,
		username: '',
		nickname: '',
		avatar: '',
		nowoption:0
	}),
	getters: {
		
	},
	actions: {
		setUserInfo(userid, username, nickname, avatar) {
			this.userid = userid;
			this.username = username;
			this.nickname = nickname;
			this.avatar = avatar;
		},
		clearUserInfo() {
			this.userid = 0;
			this.username = '';
			this.nickname = '';
			this.avatar = '';
			this.nowoption=0;
		},
		setNowOption(nowoption){
			this.nowoption=nowoption;
		}
	},
	persist: {
		enabled: true, // 开启持久化
		strategies: [
			{
				key: 'userStore', // 存储的键名
				storage: localStorage, // 存储位置，可以是 localStorage 或 sessionStorage
			},
		],
	},
});